package com.yueya.common.util;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;

public class StringUtil {

	/**
	 * 
	 * @param city
	 * @return
	 */
	public static String removeShi(String city) {
		String str = "";
		String tempStr = "";
		int index_start = 0;
		for (int index_end = 1; index_end <= city.length(); index_end++) {

			tempStr = city.substring(index_start, index_end);
			if (index_end == city.length()) {
				tempStr = tempStr.replace("市", "");
			}
			str += tempStr;
			index_start++;
		}

		return str;
	}

	public static String nf(BigDecimal sum) {
		NumberFormat nf = new DecimalFormat(",###.##");
		String testStr = nf.format(sum);// 123456789.123
		////System.out.println(testStr);
		return testStr;
	}

	/**
	 * 字符串转换unicode
	 */
	public static String string2Unicode(String string) {
		StringBuffer unicode = new StringBuffer();
		for (int i = 0; i < string.length(); i++) {
			// 取出每一个字符
			char c = string.charAt(i);
			// 转换为unicode
			unicode.append("%u" + Integer.toHexString(c));
		}
		return unicode.toString();
	}

	public static void main(String args[]) {
		//System.out.println(removeShi("赣市州市市"));
	//System.out.println(string2Unicode("吉集号货运款"));
	}
}
